package mx.com.fractal.ristorante.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class XmlDateAdapter extends XmlAdapter<String, Date>{
	
	private static final String FORMAT="yyyy-MM-dd";

	@Override
	public String marshal(Date date) throws Exception {
		SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT);
		return dateFormat.format(date);
	}

	@Override
	public Date unmarshal(String date) throws Exception {
		SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT);
		return dateFormat.parse(date);
	}
}
